<template>
<div class="management-platform views-container">
    <div class="wlm-table">
        <div class="wlm-table-hearder-btn">
            <router-link tag="span" to="/platform/managementPlatformAdd">
                <el-button size="small" type="primary">新增平台</el-button>
            </router-link>
        </div>
        <div class="wlm-table-header">
            <el-form :model="tableFormatData.platformTable.files" size="small" label-width="90px" class="retail-form" label-position="right">
                <el-form-item label="" class="filter">
                    <el-form-item label="平台名称：" class="search">
                        <el-input v-model="tableFormatData.platformTable.files.name" placeholder="请输入平台名称" style="width:160px;"></el-input>
                    </el-form-item>
                    <el-form-item label="登陆账号：" class="search">
                        <el-input v-model="tableFormatData.platformTable.files.user_name" placeholder="请输入登录账号" style="width:160px;"></el-input>
                    </el-form-item>
                </el-form-item>

                <el-form-item label="" class="filter">
                    <el-form-item label="使用状态：">
                        <el-select v-model="tableFormatData.platformTable.files.is_ban" placeholder="请选择">
                            <el-option v-for="item in [{lable:'正常',value:'0'},{lable:'禁止',value:'1'}]" :key="item.value" :label="item.lable" :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="所属用户：" class="search">
                        <el-input v-model="tableFormatData.platformTable.files.real_name" placeholder="请输入所属用户" style="width:160px;"></el-input>
                    </el-form-item>
                </el-form-item>
                <el-form-item label="" class="filter-btns">
                    <el-button v-waves type="primary" @click="filesSerch">筛选</el-button>
                    <el-button type="text" @click="filesEmpty">清空筛选条件</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div class="wlm-table-content">
            <!-- <el-tabs v-model="tableFormatData.platformTable.files.status" type="card" @tab-click="filesSerch">
        <el-tab-pane label="全部" name="0"></el-tab-pane>
      </el-tabs> -->
            <el-table :ref="tableFormatData.platformTable.key" :data="tableFormatData.platformTable.tableData" @selection-change="handleSelectionChange" style="width: 100%">
                <el-table-column type="selection" width="55" header-align="left" align="left">
                </el-table-column>
                <el-table-column prop="date" label="平台名称" header-align="left" align="left">
                    <template slot-scope="scope">
                        <span>{{scope.row.name}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="登录账号" header-align="left" align="left">
                    <template slot-scope="scope">
                        <span>{{scope.row.user_name}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="所在区域" header-align="left" align="left">
                    <template slot-scope="scope">
                        <span>{{scope.row.address}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="所属用户" header-align="left" align="left">
                    <template slot-scope="scope">
                        <span>{{scope.row.real_name}}</span>
                    </template>
                </el-table-column>
                <!-- <el-table-column prop="name" label="使用状态" header-align="left" align="left">
                    <template slot-scope="scope">
                        <span>{{scope.row.is_check == '1'?'营业中':'待审核'}}</span>
                    </template>
                </el-table-column> -->
                <el-table-column prop="name" label="剩余天数" header-align="left" align="left">
                    <template slot-scope="scope">
                        <span>{{scope.row.endtime }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="创建时间" header-align="left" align="left">
                    <template slot-scope="scope">
                        <span>{{ scope.row.startime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="状态" header-align="left" align="left">
                    <template slot-scope="scope">
                        <el-switch :active-value="0" :inactive-value="1" @change="changeTableItem({id:scope.row.id,is_ban:scope.row.is_ban},tableFormatData.platformTable.change.is_ban,{isWarning: scope.row.is_ban === 1,warning:'禁用平台后，平台将无法使用，确认禁用嘛？',cancel:{msg:'已取消',val:{scope:scope,cancelStatus:{key:'is_ban',val:0}}}})" v-model="scope.row.is_ban"> </el-switch>
                    </template>
                </el-table-column>
                <el-table-column label="操作" header-align="left" align="left">
                    <template slot-scope="scope">
                        <div class="operation-group">
                            <router-link class="wlm-text" tag="span" :to="{path:'/platform/managementPlatformAdd', query:{id:scope.row.id}}">
                                <el-button type="text">编辑</el-button>
                            </router-link>
                            <div class="btn-line"></div>
                            <el-button class="wlm-text" type="text" @click="delTableItem(scope.row.id)">删除</el-button>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-content flex-row flex-justify-b flex-align-c">
                <el-row class="pagination-btns">
                    <el-checkbox class="check-all" :disabled="!hasTableData" true-label="1" false-label="0" v-model="tableFormatData.platformTable.files.checkall" @change="toggleSelection">全部</el-checkbox>
                    <el-button class="right-8" :disabled="isGroup" size="mini" @click="delTableList">删除</el-button>
                </el-row>
                <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" 
                :current-page.sync="tableFormatData.platformTable.pagination.page" :page-sizes="tableFormatData.platformTable.pagination.pagesizes"
                 :page-size.sync="tableFormatData.platformTable.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" 
                 :total="hasTableData?tableFormatData.platformTable.pagination.total : 0">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
</template>

<script>
import {
  platformIndex,
  platformDel,
  // platformProduct,
  platformStatus
} from '@/api/platform'
import waves from '@/directive/waves' // Waves directive
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Table')],
  name: 'ManagementPlatform',
  components: {

  },
  directives: {
    waves
  },
  data() {
    return {
      tableFormatData: {
        current: 'platformTable',
        platformTable: {
          key: 'platformTable',
          api: {
            getList: platformIndex,
            delList: platformDel
          },
          tableData: [],
          files: {
            user_name: '',
            real_name: '',
            name: '',
            is_ban: '',
            ids: [],
            checkall: '0',
            Recycle: '0'
          },
          change: {
            is_ban: {
              name: '编辑',
              key: 'is_ban',
              api: platformStatus
            }
          },
          pagination: {
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0
          }
        }
      }
    }
  },
  created() {
    // this.$nextTick(() => {
    //   this.getProduct()
    // })
  },
  mounted() {

  },
  methods: {
  }
}
</script>

<style lang="scss" scoped>
.management-platform {}
</style>
